#include<bits/stdc++.h>
using namespace std;
class Vehicle
{ 
    protected:
        string no; //编号
    public:
        Vehicle(string _n):no(_n){ }
        virtual void display()=0; //应收费用
};
class Car:public Vehicle
{
    protected:
        int num,heavy;
    public:
        Car(int nu,int he,string _n):Vehicle(_n)
        {
            num=nu;
            heavy=he;
        }
        virtual void display()
        {
            cout<<no<<" "<<heavy*2+num*8<<"\n";
        }

};
class Truck:public Vehicle
{
    protected:
        int heavy;
    public:
        Truck(string _n,int he):Vehicle(_n)
        {
            heavy=he;
        }
        virtual void display()
        {
            cout<<no<<" "<<heavy*5<<"\n";
        }
};
class Bus:public Vehicle
{
    protected:
        int num;
    public:
        Bus(string _n,int nu):Vehicle(_n)
        {
            num=nu;
        }
        virtual void display()
        {
            cout<<no<<" "<<num*30<<"\n";
        }
};
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;++i)
    {
        Vehicle *pv;
        int tag,num,heavy;
        string no;
        cin>>tag>>no;
        if(tag==1)
        {
            cin>>num>>heavy;
            pv=new Car(num,heavy,no);
            pv->display();
        }
        else if(tag==2)
        {
            cin>>heavy;
            pv=new Truck(no,heavy);
            pv->display();
        }
        else if(tag==3)
        {
            cin>>num;
            pv=new Bus(no,num);
            pv->display();
        }
        delete pv;
    }
}